# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=libid3tag
pkgver=0.16.1
pkgrel=0
pkgdesc="MAD ID3 tagger for MP3 audio files"
url="https://www.underbit.com/products/mad/"
arch="all"
license="GPL-2.0-or-later"
options="!check" # no tests
makedepends="cmake samurai zlib-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/tenacityteam/libid3tag/archive/refs/tags/$pkgver.tar.gz"

# secfixes:
#   0.16.1-r0:
#     - CVE-2017-11550
#     - CVE-2017-11551

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DENABLE_TESTS=YES \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	mkdir -p "$pkgdir"/usr/lib/pkgconfig
	cat > "$pkgdir"/usr/lib/pkgconfig/id3tag.pc <<- EOF
	prefix=/usr
	exec_prefix=/usr/bin
	libdir=/usr/lib
	includedir=/usr/include

	Name: id3tag
	Description: ID3 tag manipulation library
	Requires:
	Version: $pkgver
	Libs: -lid3tag
	Cflags:
	EOF
}

sha512sums="
621cbdf7a0ea5cdca6a9133c88fb07ff0c519ed73bc26a535de3928f4784b912bb44315b45362600d53cd03083b66f38d674d1880ca30e5f6c342321977a6eb2  libid3tag-0.16.1.tar.gz
"
